<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<title>通知模式</title>
	</head>
	<body>
		<script type="text/javascript">
			let xm = null
			var wqj = {
				name: '伍祺峻',
				sex: 'male',
				npl: xm
			}
			xm = {
				name: '向妙',
				sex: 'female',
				npl: wqj
			}
			//给伍祺峻的女朋友赋值
			// Object.defineProperty(wqj,"npl",{
			// 	get:function(V){
			// 		console.log("女朋友被读取了,是"+V);
			// 	},
			// 	set:function(newV,oldV){
			// 		console.log(oldV+"变成"+newV.name);
			// 	}
			// });
			// //给伍祺峻的女朋友赋值
			// Object.defineProperty(xm,"name",{
			// 	get:function(V){
			// 		wqj.npl=xm;
			// 		console.log("name被读取");
			// 	}
			// });
			var temp=null;
			var keys=Object.keys(wqj)
			for(var data of keys){
				console.log(data)
				temp=Object.defineProperty(wqj,data,{
					get:function(value){
						// V=wqj[data]
						console.log(value)
						return data
						// return wqj[data]
					},
					set:function(oldV,newV){
						console.log(oldV,newV)
					}
				});
			}
			console.log(wqj===temp);
		</script>
	</body>
</html>
